﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrameConstructor;


namespace TetrisShape
{
    public class MainMenu
    {

        static public Field globalF;
        static int check = 1;
        private bool flag = true;

        Frame fr = new Frame();

        private InputHandler _userInputHandler;
        public MainMenu()
        { }
        public MainMenu(InputHandler handler)
        {
            Console.SetWindowSize(70, 58);
            _userInputHandler = handler;
        }
        //Set Main menu.
        public void SetMenu()
        {
            Console.CursorVisible = false;
            Console.SetCursorPosition(25, 30);
            Console.WriteLine("Start Game");
            Console.SetCursorPosition(25, 33);
            Console.WriteLine("Quit");

            fr.SetFrame(23, 29, 37, 31);
            do
            {
                ConsoleKeyInfo kInfo = Console.ReadKey();

                if (kInfo.Key == ConsoleKey.DownArrow)
                {
                    fr.ClearFrame(23, 29, 37, 31);
                    fr.SetFrame(23, 32, 37, 34);
                    check = 0;
                }
                if (kInfo.Key == ConsoleKey.UpArrow)
                {
                    fr.ClearFrame(23, 32, 37, 34);
                    fr.SetFrame(23, 29, 37, 31);
                    check = 1;
                }
                if (kInfo.Key == ConsoleKey.Enter)
                {
                    flag = false;
                }

            }
            while (flag);

            if (check == 1)
            {
                Field f = new Field(_userInputHandler);
                globalF = f;
                f.StartMoveShape();
            }
            if (check == 0)
            {
                return;
            }
        }
    }
}
